/*
 * Command pattern encapsulates a request as an object, thereby letting you parameterize clients with diferent requests, queue or
 * log requests, and supports undoable operations. The pattern has a behavioral purpose and deals with relationships between objects.
 * 
 * want to parameterize objects by an action to perform
 * want to specify, queue, and execute requests at diferent times
 * support undo
 * support logging changes so that they can be reapplied in case of a system crash
 * structure a system around high-level operations built on primitives operations
 */

#ifndef _CPP_DESIGN_PATTERN_COMMAND_H
#define _CPP_DESIGN_PATTERN_COMMAND_H

#include <iostream>

class Receiver
{
public:
    void action();
};

class Command
{
public:
    virtual ~Command() {}
    virtual void execute() = 0;

protected:
    Command() {}
};

class ConcreteCommand : public Command
{
public:
    ConcreteCommand(Receiver *);
    ~ConcreteCommand();
    void execute();

private:
    Receiver *recver_;
};

class Invoker
{
public:
    void set(Command *);
    void confirm();

private:
    Command *cmder_;
};

#endif